add registry-login input for optional registry auth before build#117
add registry-login input for optional registry auth before build#117
Conversation
1f53313 to
97e2afd
Compare
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
97e2afd to
e36e467
Compare
tonistiigi
left a comment
There was a problem hiding this comment.
I'm not sure why this isn't the default.
If this is to prevent early login for public pull then that could be handled with the scope property.
If this is needed, then why isn't it in registry auth config, per-registry?
Good point. I tested this and registry-login: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}This is similar to what we do in our repos like https://github.com/moby/buildkit-bench/blob/0ba0908a5f906bc469d6ebdca9731942432c81c9/.github/workflows/ci.yml#L81 but here we gate the login-action. Alternatively we would have a new secrets:
registry-auths: |
- registry: docker.io
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
skip: ${{ github.event_name = 'pull_request' }}Or secrets:
registry-auths: |
- registry: docker.io
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
enable: ${{ github.event_name != 'pull_request' }}WDYT? |
This PR adds an explicit
registry-logininput to both reusable workflows. It allows logging in to registries before the build step when users need to pull private images even if push isfalseor output is notimage. The input supportsauto,true, andfalse, withautokeeping current behavior by logging in only when output isimageand push istrue. The workflows now validate this input and fail when login is enabled butregistry-authsis not provided.